import React, {Component} from 'react';

class Search extends Component {
	static defaultProps = {
		searchMethods: [],
		placeholder: '关键字'
	};

	render() {
		return (
			<div className="form-inline public-search">
				<div className="form-group">
					<select
						className="form-control"
						defaultValue={this.props.select}
						onChange={e => this.props.changeSelect(e.target.value)}
					>
						{
							this.props.searchMethods.map((item, index) => {
								return <option key={index} value={item.value}>{item.title}</option>
							})
						}
					</select>
				</div>
				<div className="form-group">
					<input
						type="text"
						className="form-control"
						placeholder={this.props.placeholder}
						value={this.props.search}
						onChange={e => this.props.changeSearch(e.target.value)}
					/>
				</div>
				<button
					type="button"
					className="btn btn-default"
					onClick={this.props.clickSearch}
				>查询
				</button>
			</div>
		);
	}
}

export default Search;